package com.ruoyi.system.api.domain;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.config.Global;
import com.ruoyi.common.config.JPushConfig;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.OkHttpUtils2;
import com.ruoyi.system.api.ResponseWithData;
import com.ruoyi.system.api.mapper.*;
import com.ruoyi.system.api.service.IInterfaceOperationLogService;
import com.ruoyi.system.api.service.LocationService;
import com.ruoyi.system.api.service.PokeRequestServe;
import com.ruoyi.system.api.service.impl.CcServiceImpl;
import okhttp3.FormBody;
import okhttp3.Response;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @ClassName test
 * @Description: TODO
 * @Author shihx
 * @Date 2020/2/5
 * @Version V1.0
 **/
public class test {
    private static final Logger log = LoggerFactory.getLogger(CcServiceImpl.class);

    /**
     * 配置文件
     */
    @Autowired
    private Global global;

    /**
     * 用户表
     */
    @Autowired
    private UserMapper userMapper;

    /**
     * 接口调用日志
     */
    @Autowired
    private IInterfaceOperationLogService iInterfaceOperationLogService;

    @Autowired
    private ServiceNoticeMapper serviceNoticeMapper;

    @Autowired
    private ServiceInstrumentMapper serviceInstrumentMapper;

    @Autowired
    private InstrumentInfoMapper instrumentInfoMapper;

    @Autowired
    private LocationService locationService;

    @Autowired
    private ServicePartMapper servicePartMapper;

    @Autowired
    private ServiceDetailsMapper serviceDetailsMapper;

    @Autowired
    private PlanDetailsMapper planDetailsMapper;

    @Autowired
    private JPushConfig jPushConfig;

    @Autowired
    private JpushLogMapper jpushLogMapper;

    @Autowired
    private PokeRequestServe pokeRequestServe;


    public static void main(String[] args) throws ParseException {
        String str1 = new StringBuilder("中国").append("钓鱼岛").toString();
        System.out.println(str1.intern() == str1);

        String str2 = new StringBuilder("999999999999999999").append("2542352345").toString();
        System.out.println(str2.intern() == str2);
        Date start = DateUtils.parseDate("2020-07-31 13:01:00");
        Date end = DateUtils.parseDate("2020-08-14 14:01:00");

        long cha = workTimeDiff(start, end);
        System.out.println(cha / 60);

    }

    public static Long workTimeDiff(Date start, Date end) throws ParseException {

        long cha = (end.getTime() - start.getTime()) / (1000 * 60);
        if (DateUtils.isSameDay(start, end)) {
            return cha;
        } else {
            while (!DateUtils.isSameDay(start, end)) {
                start = DateUtils.addDays(start, 1);
                if (!DateUtils.isWeekend(DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss",start))) {
                    cha -= 24 * 60;
                } else {
                    cha -= 14 * 60;
                }

            }
        }
        return cha;
    }


}

